<?
/**
* Left Block with tickets in the Event
**/
global $infopark,$conf;
?><section id="<?php print $block_html_id; ?>" >
   <?/* <h1><? print $block->{'#node'}->title; ?></h1>*/?>
    <div class="region region-sidebar-first">
  <section id="block-spec-other-places-block-other-places">
  <?php
$first_schedule_id=0;
if(isset($_GET['evt']))
{
    $first_schedule_id=$_GET['evt'];
}

  if (count($block->{'#then'})) : ?>
		<div class="od_tbl">
                <?php foreach ($block->{'#then'} as $th) : 
			if(!$first_schedule_id)$first_schedule_id=$th->entity_id;
                        echo $infopark->draw_event_ticket($th,$block->{'#node'}->field_event_buy_a_ticket['und'][0]['value']);       
                        endforeach; 
                    
			//event in another city	 
			if (count($block->{'#exept'})):
                             
			print '<a href="javascript://" class="other_cities_link" onclick="jQuery(\'#other_cities\').show();jQuery(\'.other_cities_link\').hide()">другие города</a>';
			print '<div id="other_cities" style="display:none;">
                            <a href="javascript://" onclick="jQuery(\'#other_cities\').hide();jQuery(\'.other_cities_link\').show();" class="other_cities_close" >Свернуть другие города</a>';
				foreach ($block->{'#exept'} as $th) : 
				if(!$first_schedule_id)$first_schedule_id=$th->entity_id;
                                 echo $infopark->draw_event_ticket($th,$block->{'#node'}->field_event_buy_a_ticket['und'][0]['value']);  
				/*?>
				<div class="od schedule<?=$th->entity_id?>" onMouseOver="hightlight_thumb(<?=$th->entity_id?>);hightlight_ticket(<?=$th->entity_id?>);">
				<div class="od_left"><div class="od_date1"><a href="/events?day=<?=date('dmY',strtotime($th->field_schedule_start_value));?>"><strong><?=date('j',strtotime($th->field_schedule_start_value));?></strong><span><?=$conf['week_days_short'][date('w',strtotime($th->field_schedule_start_value))];?></span></a></div>
				<div class="od_month"><?=$conf['month_namez'][date('n',strtotime($th->field_schedule_start_value))-1];?></div>
									<div class="od_year"><?=date('Y',strtotime($th->field_schedule_start_value));?></div></div>
				<div class="od_right">
					<div class="od_place"><h4><?=l($th->title,'node/'.$th->field_schedule_place_nid);?></h4>
						<div class="city"><?=$th->name;?></div>
					</div>
									
										<div class="od_tm">Начало в <?=date('H:i',strtotime($th->field_schedule_start_value));?></div>
										<?
										if($th->field_schedule_end_value)
										{
										if(date('d',strtotime($th->field_schedule_start_value))!=date('d',strtotime($th->field_schedule_end_value)))
										{
										?><div class="od_tm">Окончание <? 
											echo date('j ',strtotime($th->field_schedule_end_value)).$conf['month_namez'][date('n',strtotime($th->field_schedule_end_value))-1];
											echo " ".date('H:i',strtotime($th->field_schedule_end_value)); 
										?></div><?
										}else{
										?>
										<div class="od_tm">Окончание <? 
											echo date('H:i',strtotime($th->field_schedule_end_value)); 
										?></div>
										<?
										}
										}
										?>
										<div>
		
		<?if(!empty($th->field_schedule_price_value)):?>
		<div class="price">Цена: <?=$th->field_schedule_price_value;?></div>
		<?endif;?>
		<?
		### orderby btn ###

		if(($block->{'#node'}->field_event_buy_a_ticket['und'][0]['value'])&&(strtotime($th->field_schedule_start_value)>time())):
		?>
		<div class="order_tickets_lnk">
		<span onclick="_gaq.push(['_trackEvent', 'buy_ticket', 'main_buy_button','choose_how_to_buy']);order_ticket_form('<?=$block->{'#node'}->nid;?>','<?=strtotime($th->field_schedule_start_value);?>')">Купить билет</span>
		</div>
		<?endif;?></div>
										</div>
				</div><?php 
                                 */ 
                                  endforeach;
                                 
                       
			print "</div>";
			endif;
                        
			 ?>
				 </div>
                                 <?
                                 
                                 if($first_schedule_id)
				 {
                                 drupal_add_js('misc/front.js');
				 ?>
				 <script>
				 jQuery(document).ready(function () {
				 hightlight_thumb(<?=$first_schedule_id;?>);
				 hightlight_ticket(<?=$first_schedule_id;?>);
                                 move_scroll('.filters','.schedule<?=$first_schedule_id;?>');
				 });
				 </script>
				 <?
				 }
                                 ?>
            <?php else : ?>

                <div class="one_date past">
                    <h4>Событие уже прошло в</h4>
<?
#pre($block->{'#node'});
$places=$infopark->get_place_by_event($block->{'#node'}->nid,'past');
foreach($places as $pl)echo '<p>'.l($pl->title,'node/'.$pl->nid).' '.$infopark->draw_dm($pl->field_schedule_start_value).' </p>';
?>
                </div>
                                 
                                 
            <?php endif; 
            
            #### OTHER TICKETS ###
            
            if(count($block->{'#node'}->field_event_category['und']))
            {
                $cc =advert_compromise_get_citydomain($_SERVER['HTTP_HOST']);
                $current_city=$cc['tid'];
                foreach(taxonomy_get_tree(6) as $cc)$cities_list[$cc->tid]=$cc->name;

                foreach(taxonomy_get_tree(8) as $cc)$categories_names[$cc->tid]=$cc->name;
                
              #  pre($categories_list);
            $first_cat=0;
            echo '<ul class="filter_categories">';
            foreach($block->{'#node'}->field_event_category['und'] as $term)
            {
                if(!in_array($term['taxonomy_term']->tid,array(111,157)))
                {
                    if(!$first_cat)$first_cat=$term['taxonomy_term']->tid;
                    #l($term['taxonomy_term']->name,'events',array('query'=>array('tid'=>$term['taxonomy_term']->tid)))
                 print '<li class="other_tickets other_ticket'.$term['taxonomy_term']->tid.'" onclick="other_opn('.$term['taxonomy_term']->tid.')">Другие '.$term['taxonomy_term']->name."</li>";
                
                 print '<div class="other_blocks other_block'.$term['taxonomy_term']->tid.'" style="display:none">';
                 
                
                 $others=$infopark->get_other_events_w_ticket($block->{'#node'}->nid,$term['taxonomy_term']->tid);
                # print $other;
                 foreach($others as $oth_event)
                 {
                    # pre($oth_event);
                     $categories_list = _spec_events_category_list($oth_event->nid);
                     $oth_event->categories=$categories_list[$oth_event->nid];
                    
                   # $oth_event->is_recommended=((in_array(111, $oth_event->categories))?true:false);
                    $oth_event->is_recommended=$oth_event->field_recommended_value;
                     $arg=array('e'=>$oth_event,
			'current_city'=>$current_city,
			'categories_names'=>$categories_names,
			'cities_list'=>$cities_list);
                     print '<div class="pin">'._spec_event($arg)."</div>";
                       #print '<div class="pin">'.($oth_event->is_recommended?  _spec_event_recommended($arg):_spec_event($arg))."</div>";
                 }
                 #print '<p class="moretickets">'.l('Ещё с билетами: '.$term['taxonomy_term']->name,'events',array('query'=>array('tid'=>$term['taxonomy_term']->tid))).'</p>';
                 
                 
                 print '<div class="moretickets">'.l('Ещё с билетами: '.$term['taxonomy_term']->name,'events',array('query'=>array('tid'=>$term['taxonomy_term']->tid))).'</div>';
                
                 print '</div>';
                 }
                
            }
            echo '</ul>';
           /* if($first_cat)
                {
                echo '<script>other_opn('.$first_cat.')</script>';
                }*/
            }
             
            ?>
            
           
	        <div class="right_banner"><?php if ($page['navigation']):print render($page['navigation']);endif; ?>
  
                </div>                   
                                 
        </section>
    </div>
</section>

<?php if (count($block->{'#related_events'})) : ?>
<div class="related_events">
<h3>Похожие события</h3>
<ul>
<?php foreach ($block->{'#related_events'} as $e) : ?>

<li><?=l($e->title,'node/'.$e->nid);?></li>
<?php endforeach;?>
</ul></div>
<?php endif; ?>